---
image: /generated/articles-docs-studio-delete-static-file.png
title: deleteStaticFile()
crumb: "@remotion/studio"
---

# deleteStaticFile()<AvailableFrom v="4.0.154"/>

Deletes a file from the [`public` directory](/docs/terminology/public-dir).  
This API is useful for building interactive experiences in the [Remotion Studio](/docs/terminology/studio).

## Examples

```tsx twoslash title="Delete 'video.webm'"
import React, { useCallback } from "react";
import { deleteStaticFile } from "@remotion/studio";

export const DeleteStaticFileComp: React.FC = () => {
  const deleteFile = useCallback(async () => {
    const { existed } = await deleteStaticFile("video.webm");

    console.log(`Deleted file (${existed ? "existed" : "did not exist"})`);
  }, []);

  return <button onClick={deleteFile}>Delete</button>;
};
```

## Rules

<Step>1</Step> This API can only be used while in the Remotion Studio.
<br />
<Step>2</Step> The file path must be relative to the <a href="/docs/terminology/public-dir">
  <code>public</code> directory
</a>.
<br />
<Step>3</Step> It's not allowed to delete a file outside the <a href="/docs/terminology/public-dir">
  <code>public</code> directory
</a>.<br />
<Step>4</Step> To delete a file in a subfolder, use forward slashes <code>
  /
</code> even on Windows.
<Step>5</Step> You can, but don't have to wrap the file path in a <a href="/docs/staticfile">
  <code>staticFile()</code>
</a> function.

## See also

- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/studio/src/api/delete-static-file.ts)
- [`writeStaticFile()`](/docs/studio/write-static-file)
- [`getStaticFiles()`](/docs/studio/get-static-files)
- [`watchStaticFile()`](/docs/studio/watch-static-file)
